﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;

namespace 控制台应用
{
    public class SortClass
    {
        #region List集合排序
        /// <summary>
        /// List集合排序
        /// </summary>
        public void sortList()
        {
            List<User> lists = new List<User>();
            lists.Add(new User() { userName = "张三", userAge = "19" });
            lists.Add(new User() { userName = "李四", userAge = "18" });
            lists = lists.OrderBy(obj => obj.userAge).ToList();

            string[] user = new string[] { "000", "sa", "admin" };
            DataTable testDT = new DataTable();
            testDT.Columns.Add("UserID");
        }
        #endregion

        #region 数组排序

        #region 冒泡排序

        #region Int数组排序
        public void SortIntArray(int[] intArray)
        {
            for (int i = 0, temp = 0; i < intArray.Length; i++)
            {
                for (int j = i + 1; j < intArray.Length; j++)
                {
                    if (intArray[i] > intArray[j])
                    {
                        temp = intArray[i];
                        intArray[i] = intArray[j];
                        intArray[j] = temp;
                    }
                }
            }
        }
        #endregion
        
        #endregion



        #endregion
    }
}
